﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace pswb.Forms.ProcessEdit
{
    public partial class frmProcessProperties : Form
    {
        private bool allowClose = false;

        public string ProcessName { get; set; }

        public frmProcessProperties()
        {
            InitializeComponent();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            if (txtProcessName.Text == string.Empty)
            {
                txtProcessName.BackColor = Color.LightSalmon;
                txtProcessName.Focus();
                allowClose = false;
            }
            else
            {
                ProcessName = txtProcessName.Text;
                allowClose = true;
            }
        }

        private void frmProcessProperties_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (e.CloseReason == CloseReason.UserClosing)
                e.Cancel = false;
            else
                e.Cancel = !allowClose;
        }

        private void txtProcessName_TextChanged(object sender, EventArgs e)
        {
            txtProcessName.BackColor = Color.White;
        }

        private void btnCalcel_Click(object sender, EventArgs e)
        {
            allowClose = true;
        }
    }
}
